package com.yl.pattern.behavioralmodel.iterator;

/**
 * @Author 小羊
 * @Date 1/11/2024下午 4:17
 * @ClassName Client
 * @Description Client
 */
public class Client {
    public static void main(String[] args) {
        StudentAggregateImpl aggregate = new StudentAggregateImpl();
        //添加元素
        aggregate.addStudent(new Student("张三","001"));
        aggregate.addStudent(new Student("李四","002"));
        aggregate.addStudent(new Student("王五","003"));

        //获取迭代器对象
        StudentIterator iterator = aggregate.getStudentIterator();
        while (iterator.hasNext()){
            Student student = iterator.next();
            System.out.println(student.toString());
        }
    }
}
